home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / -in_the_mag- / emulation / consoles / vision-8 / sources / chip8.h < prev    next >
C/C++ Source or Header  |  1997-12-12  |  3KB  |  58 lines

  1. /** Vision8: CHIP8 emulator *************************************************/
  2. /**                                                                        **/
  3. /**                                CHIP8.h                                 **/
  4. /**                                                                        **/
  5. /** This file contains the portable CHIP8 emulation engine definitions     **/
  6. /**                                                                        **/
  7. /** Copyright (C) Marcel de Kogel 1997                                     **/
  8. /**     You are not allowed to distribute this software commercially       **/
  9. /**     Please, notify me, if you make any changes to this file            **/
  10. /****************************************************************************/
  11.  
  12. #ifndef __CHIP8_H
  13. #define __CHIP8_H
  14.  
  15. typedef unsigned char byte;                     /* sizeof(byte)==1          */
  16. typedef unsigned short word;                    /* sizeof(word)>=2          */
  17.  
  18. struct chip8_regs_struct
  19. {
  20.  byte alg[16];                                  /* 16 general registers     */
  21.  byte delay,sound;                              /* delay and sound timer    */
  22.  word i;                                        /* index register           */
  23.  word pc;                                       /* program counter          */
  24.  word sp;                                       /* stack pointer            */
  25. };
  26.  
  27. extern struct chip8_regs_struct chip8_regs;
  28.  
  29. extern byte chip8_iperiod;                      /* number of opcodes per    */
  30.                                                 /* timeslice (1/50sec.)     */
  31. extern byte chip8_keys[16];                     /* if 1, key is held down   */
  32. extern byte chip8_display[64*32];               /* 0xff if pixel is set,    */
  33.                                                 /* 0x00 otherwise           */
  34. extern byte chip8_mem[4096];                    /* machine memory. program  */
  35.                                                 /* is loaded at 0x200       */
  36. extern byte chip8_running;                      /* if 0, emulation stops    */
  37.  
  38. void chip8_execute (void);                      /* execute chip8_iperiod    */
  39.                                                 /* opcodes                  */
  40. void chip8_reset (void);                        /* reset virtual machine    */
  41. void chip8 (void);                              /* start chip8 emulation    */
  42.  
  43. void chip8_sound_on (void);                     /* turn sound on            */
  44. void chip8_sound_off (void);                    /* turn sound off           */
  45. void chip8_interrupt (void);                    /* update keyboard,         */
  46.                                                 /* display, etc.            */
  47.  
  48. #ifdef DEBUG
  49. extern byte chip8_trace;                        /* if 1, call debugger      */
  50.                                                 /* every opcode             */
  51. extern word chip8_trap;                         /* if pc==trap, set trace   */
  52.                                                 /* flag                     */
  53. void chip8_debug (word opcode,struct chip8_regs_struct *regs);
  54. #endif
  55.  
  56. #endif          /* __CHIP8_H */
  57.  
  58.